<!--查看应聘者，米娜事，考核，录用-->
<template>
  <div id="cornerComment" v-if="dialogVisible">
    <div class="cornerComment-in" ref="dialogBox">
      <div class="cornerComment-in-title">
        <span>学历管理</span>
        <span class="el-icon-circle-close close-Btn-line" @click="closePOpup"></span>
      </div>
      <div class="commentBody">
        <el-button type="primary" @click="editEducationFn(0)" size="small" class="mb-10">添加学历</el-button>
        <!--本体列表，数据 -->
        <div class="table-body">
          <div class="table-body-box">
            <el-table
                ref="multipleTable"
                :data="arryList"
                :border="tableoption.tableBorder"
                :height="tableHeight"
                tooltip-effect="dark">
              <el-table-column
                  label="名称"
                  align="center"
                  prop="name">
              </el-table-column>
              <el-table-column
                  label="操作"
                  align="center">
                <template slot-scope="scope">
                  <el-button size="small" @click="editEducationFn(scope.row.id)">编辑</el-button>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>
        <!--工具条 分页-->
        <el-col :span="24" class="toolbarLine">
          <el-pagination
              background
              :page-size="page.pagesize"
              :current-page="page.pageindex"
              layout="total, prev, pager, next"
              :total="page.total"
              @current-change="handleSizeChange"></el-pagination>
        </el-col>
      </div>
      <div class="cornerComment-in-footer">
        <el-button @click="closePOpup" size="small">返回</el-button>
      </div>
    </div>
    <educationEdit :visible.sync="educationEditVisible" :editId="editId" @InitFn="InitFn"></educationEdit>
  </div>
</template>

<script>
import {pagination, tableoption} from '@/utils/util.js'
import educationEdit from "./edit"

export default {
  props: ['visible', 'resumeType'], // commoent 学生点评 collection 学生采集
  components: {
    educationEdit
  },
  data() {
    return {
      dialogVisible: false,
      tableoption: tableoption,
      editId: 0,
      page: {
        pageindex: pagination.pageIndex,
        pagesize: pagination.pageSize,
        total: pagination.total
      },
      arryList: [],
      tableHeight: 0,
      educationEditVisible: false
    }
  },
  watch: {
    visible() {
      this.dialogVisible = this.visible
      if (this.visible) {
        let n = this;
        this.$nextTick(() => {
          let height = n.$refs.dialogBox.offsetHeight;  //top 50 1 search 50 page 50 10 footer 50 1
          this.tableHeight = height - (51 + 50 + 60 + 51)
        })
        this.InitFn()
      } else {
        this.arryList = []
      }
    }
  },
  created() {
  },
  methods: {
    // 初始化
    async InitFn() {
      let option = {
        p: this.page.pageindex
      };
      let data = await this.$fetch(this.api.recruit.education.index, option);
      console.log('data:', data)
      this.arryList = data.list
      this.page.total = data.list.length
    },
    editEducationFn(id) {
      this.editId = id;
      this.educationEditVisible = true;
    },
    // 分页
    handleSizeChange(val) {
      this.page.pageindex = val
      this.InitFn()
    },
    // 关闭弹窗
    closePOpup() {
      this.$emit('update:visible', false)
    }
  },
  mounted() {
  }
}
</script>
<style scoped>
#cornerComment {
  height: 100vh;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9;
}

.cornerComment-in {
  width: 50%;
  height: 60%;
  background: #fff;
  display: flex;
  flex-direction: column;
  border-radius: 5px;
}

.cornerComment-in-title {
  height: 50px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ddd;
  font-size: 24px;
}

.cornerComment-in-title span {
  padding: 0 10px;
}

.cornerComment-in-title span:first-child {
  flex: 1;
  font-size: 16px;
}

.cornerComment-in-footer {
  height: 50px;
  border-top: 1px solid #ddd;
  display: flex;
  align-items: center;
  padding: 0 10px;
  justify-content: center;
}

.commentBody {
  padding: 10px;
  flex: 1;
  overflow-y: auto;
}

.close-Btn-line {
  cursor: pointer;
}

.toolbarLine {
  text-align: center;
}
</style>


